package com.alibaba.algo.apiimpl.feign;

import com.alibaba.algo.Application;
import com.alibaba.algo.cooperation.common.BaseResult;
import com.alibaba.algo.cooperation.common.PagerEntity;
import com.alibaba.algo.cooperation.feign.service.OrgFeignService;
import com.alibaba.algo.cooperation.feign.vo.req.*;
import com.alibaba.algo.cooperation.feign.vo.res.FeignRoleListResponseVO;
import com.alibaba.algo.cooperation.feign.vo.res.OrgUserInfoResVO;
import com.alibaba.algo.cooperation.feign.vo.res.PositionUserInfoResVO;
import com.alibaba.algo.cooperation.feign.vo.res.RpcUserInfoVO;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.ArrayList;
import java.util.List;

/**
 * @author : WangZhiPan
 * @date : 2021/10/13 14:49
 */
@SpringBootTest(classes = Application.class)
@RunWith(SpringRunner.class)
@Slf4j
public class RoleFeignServiceImplTest {

    @Autowired
    RoleFeignServiceImpl roleFeignService;

    @Autowired
    UserFeignServiceImpl userFeignService;

    @Autowired
    OrgFeignServiceImpl orgFeignService;

    @Autowired
    PositionFeignServiceImpl positionFeignService;

    @Test
    public void testSelectPage() {
        FeignSelectRoleListRequestVO vo = new FeignSelectRoleListRequestVO();
        vo.setSearchKey("29");
        BaseResult<PagerEntity<FeignRoleListResponseVO>> resp = roleFeignService.selectPage(vo);
        log.info("resp=={}", JSON.toJSONString(resp));
    }


    @Test
    public void testSelectUserListByRoleIdListOrAppCodeList() {

        SelectUserListByRoleIdListReqVO vo = new SelectUserListByRoleIdListReqVO();
        List<Long> rolelist = new ArrayList();
        rolelist.add((long) 1);
        rolelist.add((long) 2);
        vo.setRoleIdList(null);
        vo.setAppCode("MOM");

        BaseResult<List<RpcUserInfoVO>> baseResult = roleFeignService.selectUserListByRoleIdListOrAppCodeList(vo);
        System.out.println(baseResult.toString());
    }

    @Test
    public void t2() {
        SelectUserListInfoReqVo vo = new SelectUserListInfoReqVo();
        List<String> userIdList = new ArrayList<>();
        userIdList.add("18099123232");
        userIdList.add("13123451111");

        vo.setMobilephoneList(userIdList);
        BaseResult<List<RpcUserInfoVO>> baseResult = userFeignService.qryUserInfoByUserListOrAppCode(vo);
    }


    @Test
    public void t3() {
        SelectOrgUserReqVO vo = new SelectOrgUserReqVO();
        List<String> list = new ArrayList<>();
        list.add("1");
        list.add("90");
        list.add("2");
        list.add("1");
        list.add("119");
        list.add("120");
        list.add("122");
        list.add("121");
        list.add("67");


        vo.setOrgIdList(list);
        BaseResult<List<OrgUserInfoResVO>> baseResult = orgFeignService.qryUserListByOrg(vo);
        System.out.println(baseResult);
    }

    @Test
    public void t4() {
        List<Long> positionIdList = new ArrayList<>();
        SelectPositionUserReqVO vo = new SelectPositionUserReqVO();
        positionIdList.add(49L);
        positionIdList.add(52L);
        positionIdList.add(63L);
        vo.setPositionIdList(positionIdList);
        BaseResult<List<PositionUserInfoResVO>> baseResult = positionFeignService.qryUserListByPositionId(vo);
        System.out.println(baseResult);
    }


    @Test
    public void testPositionCodes() {
        List<String> codes = new ArrayList<>();
        SelectPositionUserReqVO vo = new SelectPositionUserReqVO();
        codes.add("1234");
//        codes.add(52L);
//        codes.add(63L);
        vo.setPositionCodes(codes);
        BaseResult<List<PositionUserInfoResVO>> baseResult = positionFeignService.qryUserListByPositionId(vo);
        log.info("resp==={}", JSON.toJSONString(baseResult, true));
    }

}
